import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)

const state = {
  currentRouter: {},
  preRouter: {},
}

const mutations = {
  update(state, data) {
    const { to = '', from = '' } = data
    if (to != '') state.currentRouter = to
    if (from != '') state.preRouter = from
  },
}

const getters = {
  currentRouter: (state) => state.currentRouter,
  preRouter: (state) => state.preRouter,
}
export default new Vuex.Store({
  state,
  mutations,
  getters,
})
